﻿@using Kugar.MVC.MobileUI.WeUI
@using Kugar.MVC.MobileUI.WeUI.Enum
@using Kugar.MVC.MobileUI.WeUI.Helpers
@using Kugar.MVC.MobileUI.WeUI.Helpers.Forms

@{
    ViewBag.Title = "FormTest";

    this.Layout = WebUI.DefaultLayoutPath;

    this.EnablePullToRefresh("onRefresh(e);");
    this.EnableLoadingMore("onloadmore(e);");
}

@using (var frm = WebUI.Form().Css("weui-grids").Render())
{
    @frm.AddLabel().Label("标签").Value("oooppp").Render()

    @frm.AddTextBox().Placeholder("test").Value("ssss").Name("textbox").Label("ssss").Render()

    @frm.AddDatePicker().Tips("提示:sdddddddddddddddddddddddddddd").Type(DatePickerTypeEnum.Date).Name("d1").Value(DateTime.Now).Label("d1").Render()

    @frm.AddSelector().Options(new[]
                                   {
                       new SelectorItem("dddd", "ppp"),
                   }).Label("ddd").Render()

    @frm.AddSingleImage().Name("nnnn").Label("singleimage").Ajax("FileUpload").Render()

    @frm.AddMultiImage().Name("nn111").Label("multiimage").Ajax("FileUpload2").ImageUrls(new[]
                                                                                             {
                                                                                 "/uploads/images/IMG_20180329_211809R.jpg",
                                                                                 "/uploads/images/IMG_20180329_211809R.jpg"
                                                                             }).Render()

    @(frm.AddSwipeout().InnerField(frm.AddTextBox().Placeholder("test").Value("ssss").Name("textbox").Label("左滑文本框"))
                  .AddButton(btn => btn.Text("删除").Type(ButtonTypeEnum.Button).OnClick("WebUIJS.Toptip('ssss');"))
                  .Render())

    using (frm.AddSwipeoutContainer()
            .AddButton(btn => btn.Text("删除").Type(ButtonTypeEnum.Button).OnClick("WebUIJS.Toptip('ssss');"))
            .Render()
        )
    {
        @frm.AddSwitchButton().Name("左滑swwitch").Label("SwitchButton").Checked(true).Render()
    }

    @frm.AddSwitchButton().Name("sss").Label("SwitchButton").Checked(true).Render()

    @frm.AddCounter().CounterLabel("ssss").Label("Counter").Value(20).Render()

    @frm.AddMobileVCode().Label("mobilevcode").Value("sss").Render()

    @frm.AddVCode().Label("vcode").Value("555").Render()

    @frm.AddCitySelector().Label("城市").PickerTItle("ppppp").Value("北京 北京市 东城区").Render()

    @frm.AddRadioList().Label("单选").Name("ssss").Options(new[]
                                                             {
                                                 new SelectorItem("ooo", "1"),
                                                 new SelectorItem("44", "44"),
                                             }).Render()

    @frm.AddCheckBoxList().Label("多选").Name("ssss2").Options(new[]
                                                                 {
                                                     new SelectorItem("ooo", "1"),
                                                     new SelectorItem("44", "44"),
                                                 }).Render()

    @frm.AddTextarea().Label("多行文本").Name("txa").Value("lllllllllllll").Placeholder("ooooo").Render()

    @frm.AddButtonArea().AddButton(x => x.Type(ButtonTypeEnum.Button).OnClick("showModal('/Home/ModalTest')").ButtonStyle(ButtonStyleType.Primary).Text("ModalTest")).Render()

    @*@frm.AddCheckBoxList().Label("多选").Name("ssss2").Options(new[]
                         {
            new SelectorItem("ooo", "1"),
            new SelectorItem("44", "44"),
        }).Render()*@
}

@section Scripts{
    <script>
        function showModal(url) {
            WebUIJS.ModalByUrl(url,
                null,
                function() {
                    console.log("ssss");
                },
                function() {
                    console.log("close");
                });
        }

        function showMsgPage(url) {
            WebUIJS.ShowMsgPageByUrl(url,
                null,
                function() {
                    console.log("111");
                },
                function() {
                    console.log("close2");
                });
        }

        function onRefresh(e) {
            console.log("refressh end");
            //$(sender).pullToRefreshDone();
            e.LoadComplete();
        }

        function onloadmore(e) {
            e.LoadComplete();
            console.log("load completed");
        }

        $(document).ready(function() {
            //WebUIJS.ScrollSpy($("#listview"),
            //    $(".instest"),
            //    function(e) {
            //        console.log(e);
            //    });

            //var obj = $(".instest").infinite();
            //obj.on("infinite",
            //    function(e) {
            //        console.log(e);
            //    });
        });
    </script>
}